

-module( chat_to_sl ).

-author( "chenyiming" ).

-import(proplists, [get_value/2]).

-export([ handle/1 ]).


handle( Params ) ->
    {ok,Im} =       application:get_env(ham_server, emqttd),
  	AppUid =        get_value(<<"send_uid">>,   Params),
	ToUsername =    get_value(<<"to_list">>,    Params),
	Content =       get_value(<<"content">>,    Params),
    Extra0 =         get_value(<<"extra">>,      Params),    

    Extra =
    case Extra0 of
        undefined ->
            [];
        _NotEmpty ->
            Extra0
    end,

    util:print(" chat to AppUid:~p ToUsername:~p Extra:~p Content:~p ~n",[ AppUid, ToUsername, Extra, Content]),
	cast_svc:cast(Im, emqttd_ham, to_msg_ham_list, [AppUid, ToUsername, packet_id, Extra, Content]),
	{ok, [{<<"code">>,0}]}.
